import { like, star } from '@/api/forum'
export default {
  actions: {
    like ({ commit, rootState }, id) {
      const { _id } = rootState.User.user
      return new Promise((resolve, reject) => {
        like(id, _id).then(() => {
          commit('like', id)
          resolve()
        }).catch(error => {
          reject(error)
        })
      })
    },
    star ({ commit, rootState }, id) {
      const { _id } = rootState.User.user
      return new Promise((resolve, reject) => {
        star(id, _id).then(() => {
          commit('star', id)
          resolve()
        }).catch(error => {
          reject(error)
        })
      })
    }
  }
}
